package com.linsen.core.oauth2.handler;

import cn.dev33.satoken.exception.NotLoginException;
import cn.dev33.satoken.oauth2.exception.SaOAuth2Exception;
import com.linsen.core.common.util.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author zhaoyong
 * @date 2023/3/12
 */
@Slf4j
@Order(Ordered.HIGHEST_PRECEDENCE)
@RestControllerAdvice
public class SaOAuth2ExceptionHandler {
    @ExceptionHandler(SaOAuth2Exception.class)
    public Result handleSaOAuth2Exception(SaOAuth2Exception e) {
        return Result.error(e.getMessage());
    }
}
